﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace SingleBlog.Core.Data
{
    /// <summary>
    /// 文章回复
    /// </summary>
    [Table("Comments")]
    public class Comment
    {
        [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Display(Name ="回复内容")]
        [Required(ErrorMessage ="{0}不能为空")]
        public string Content { get; set; }

        /// <summary>
        /// 文章Id
        /// </summary>
        public int ArticleId { get; set; }

        /// <summary>
        /// 匿名用户的信息
        /// </summary>
        public string AnonymouseUserInfo { get; set; }

        public int? ParentId { get; set; }

        /// <summary>
        /// 创建时间。
        /// </summary>
        public DateTime CreatedTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 关联的文章
        /// </summary>
        public virtual Article Article { get; set; }

        /// <summary>
        /// 子回复
        /// </summary>
        public virtual ICollection<Comment> ChildComments { get; set; } = new HashSet<Comment>();

        /// <summary>
        /// 父回复
        /// </summary>
        public virtual Comment ParentComment { get; set; }
    }
}
